<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>[linux]虚拟机&amp;linux基础开发环境配置(详) - Never Give Up</title>
  <meta name="renderer" content="webkit" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>

<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<meta name="theme-color" content="#f8f5ec" />
<meta name="msapplication-navbutton-color" content="#f8f5ec">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#f8f5ec">


<meta name="author" content="ZhangKQ" /><meta name="description" content="虚拟机&amp;amp;linux基础开发环境配置 1.新建虚拟机 新建虚拟机 设置磁盘位置/大小 设置cpu 设置内存 设置网络 2.安装系统 选择光盘位置-安装" /><meta name="keywords" content="linux, 虚拟机, 开发环境, 配置" />






<meta name="generator" content="Hugo 0.92.0 with theme even" />


<link rel="canonical" href="https://blog.nevergiveup.tech/post/linux/%E8%99%9A%E6%8B%9F%E6%9C%BAlinux%E5%9F%BA%E7%A1%80%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">



<link href="/sass/main.min.b5a744db6de49a86cadafb3b70f555ab443f83c307a483402259e94726b045ff.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.css" integrity="sha256-7TyXnr2YU040zfSP+rEcz29ggW4j56/ujTPwjMzyqFY=" crossorigin="anonymous">


<meta property="og:title" content="[linux]虚拟机&amp;linux基础开发环境配置(详)" />
<meta property="og:description" content="虚拟机&amp;linux基础开发环境配置 1.新建虚拟机 新建虚拟机 设置磁盘位置/大小 设置cpu 设置内存 设置网络 2.安装系统 选择光盘位置-安装" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://blog.nevergiveup.tech/post/linux/%E8%99%9A%E6%8B%9F%E6%9C%BAlinux%E5%9F%BA%E7%A1%80%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/" /><meta property="article:section" content="post" />
<meta property="article:published_time" content="2020-09-22T16:37:56+08:00" />
<meta property="article:modified_time" content="2022-02-10T16:37:56+08:00" />

<meta itemprop="name" content="[linux]虚拟机&amp;linux基础开发环境配置(详)">
<meta itemprop="description" content="虚拟机&amp;linux基础开发环境配置 1.新建虚拟机 新建虚拟机 设置磁盘位置/大小 设置cpu 设置内存 设置网络 2.安装系统 选择光盘位置-安装"><meta itemprop="datePublished" content="2020-09-22T16:37:56+08:00" />
<meta itemprop="dateModified" content="2022-02-10T16:37:56+08:00" />
<meta itemprop="wordCount" content="1475">
<meta itemprop="keywords" content="linux,虚拟机,开发环境,配置," /><meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="[linux]虚拟机&amp;linux基础开发环境配置(详)"/>
<meta name="twitter:description" content="虚拟机&amp;linux基础开发环境配置 1.新建虚拟机 新建虚拟机 设置磁盘位置/大小 设置cpu 设置内存 设置网络 2.安装系统 选择光盘位置-安装"/>

<!--[if lte IE 9]>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/classlist/1.1.20170427/classList.min.js"></script>
<![endif]-->

<!--[if lt IE 9]>
  <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]-->

</head>
<body>
  <div id="mobile-navbar" class="mobile-navbar">
  <div class="mobile-header-logo">
    <a href="/" class="logo">Never Give Up</a>
  </div>
  <div class="mobile-navbar-icon">
    <span></span>
    <span></span>
    <span></span>
  </div>
</div>
<nav id="mobile-menu" class="mobile-menu slideout-menu">
  <ul class="mobile-menu-list">
    <a href="/">
        <li class="mobile-menu-item">主页</li>
      </a><a href="/post/">
        <li class="mobile-menu-item">归档</li>
      </a><a href="/tags/">
        <li class="mobile-menu-item">标签</li>
      </a><a href="/categories/">
        <li class="mobile-menu-item">分类</li>
      </a><a href="/remark/">
        <li class="mobile-menu-item">随言碎语</li>
      </a><a href="/about/">
        <li class="mobile-menu-item">关于</li>
      </a>
  </ul>

  


</nav>

  <div class="container" id="mobile-panel">
    <header id="header" class="header">
        <div class="logo-wrapper">
  <a href="/" class="logo">Never Give Up</a>
</div>





<nav class="site-navbar">
  <ul id="menu" class="menu">
    <li class="menu-item">
        <a class="menu-item-link" href="/">主页</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/post/">归档</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/tags/">标签</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/categories/">分类</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/remark/">随言碎语</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/about/">关于</a>
      </li>
  </ul>
</nav>

    </header>

    <main id="main" class="main">
      <div class="content-wrapper">
        <div id="content" class="content">
          <article class="post">
    
    <header class="post-header">
      <h1 class="post-title">[linux]虚拟机&amp;linux基础开发环境配置(详)</h1>

      <div class="post-meta">
        <span class="post-time"> 2020-09-22 </span>
        <div class="post-category">
            <a href="/categories/linux/"> linux </a>
            </div>
          <span class="more-meta"> 约 1475 字 </span>
          <span class="more-meta"> 预计阅读 3 分钟 </span>
        
      </div>
    </header>

    <div class="post-toc" id="post-toc">
  <h2 class="post-toc-title">文章目录</h2>
  <div class="post-toc-content always-active">
    <nav id="TableOfContents">
  <ul>
    <li>
      <ul>
        <li><a href="#虚拟机linux基础开发环境配置">虚拟机&amp;linux基础开发环境配置</a>
          <ul>
            <li><a href="#1新建虚拟机">1.新建虚拟机</a></li>
            <li><a href="#2安装系统">2.安装系统</a></li>
            <li><a href="#3设置网络">3.设置网络</a></li>
            <li><a href="#4linux基础配置">4.linux基础配置</a></li>
            <li><a href="#5安装git">5.安装git</a></li>
            <li><a href="#6安装基础环境">6.安装基础环境</a></li>
            <li><a href="#7安装linux_init项目">7.安装linux_init项目</a></li>
            <li><a href="#8lnmp环境配置">8.lnmp环境配置</a></li>
            <li><a href="#9docker和docker-compose环境">9.docker和docker-compose环境</a></li>
            <li><a href="#10golang环境配置">10.golang环境配置</a></li>
          </ul>
        </li>
      </ul>
    </li>
  </ul>
</nav>
  </div>
</div>
    <div class="post-content">
      <h2 id="虚拟机linux基础开发环境配置">虚拟机&amp;linux基础开发环境配置</h2>
<h3 id="1新建虚拟机">1.新建虚拟机</h3>
<ul>
<li>新建虚拟机</li>
<li>设置磁盘位置/大小</li>
<li>设置cpu</li>
<li>设置内存</li>
<li>设置网络</li>
</ul>
<h3 id="2安装系统">2.安装系统</h3>
<ul>
<li>选择光盘位置-安装系统-设置root账号密码</li>
</ul>
<h3 id="3设置网络">3.设置网络</h3>
<ul>
<li>虚拟机设置网络为桥接,自动获取</li>
<li>进入虚拟机并配置:</li>
</ul>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span><span class="lnt">8
</span><span class="lnt">9
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="c1">#查看网络名</span>
ifconfig 或者 ip addr
<span class="c1">#编辑网络配置文件</span>
vi /etc/sysconfig/network-scripts/ifcfg-ens33
<span class="o">[</span>修改内容<span class="o">]</span>
<span class="nv">ONBOOT</span><span class="o">=</span>yes

<span class="c1">#使配置生效</span>
systemctl restart network
</code></pre></td></tr></table>
</div>
</div><ul>
<li>测试外网链接</li>
</ul>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash">curl www.baidu.com
</code></pre></td></tr></table>
</div>
</div><ul>
<li>如果没有网络,设置静态地址</li>
</ul>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash">vi /etc/sysconfig/network-scripts/ifcfg-ens33
<span class="o">[</span>修改内容<span class="o">]</span>
<span class="nv">BOOTPROTO</span><span class="o">=</span>static
<span class="nv">IPADDR</span><span class="o">=</span>192.168.20.72
<span class="nv">NETMASK</span><span class="o">=</span>255.255.255.0
<span class="nv">GATEWAY</span><span class="o">=</span>192.168.20.254
<span class="nv">DNS1</span><span class="o">=</span>8.8.8.8
<span class="nv">DNS2</span><span class="o">=</span>114.114.114.114

<span class="c1">#使配置生效</span>
systemctl restart network
</code></pre></td></tr></table>
</div>
</div><ul>
<li>多网络设置</li>
</ul>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="c1">#复制网络配置文件</span>
cp /etc/sysconfig/network-scripts/ifcfg-ens0 /etc/sysconfig/network-scripts/ifcfg-ens1
<span class="c1">#编辑新增的配置文件</span>
vi /etc/sysconfig/network-scripts/ifcfg-ens1
<span class="o">[</span>修改内容<span class="o">]</span>
<span class="nv">NAME</span><span class="o">=</span>eth1
<span class="nv">DEVICE</span><span class="o">=</span>eth1
<span class="nv">ONBOOT</span><span class="o">=</span>no

<span class="c1">#使配置生效</span>
systemctl restart network
</code></pre></td></tr></table>
</div>
</div><h3 id="4linux基础配置">4.linux基础配置</h3>
<ul>
<li>
<p>添加yum软件源</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span><span class="lnt">8
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback">cd /etc/yum.repos.d/
mkdir backupdy
mv C* backupdy
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
yum -y install yum-utils
sudo yum-config-manager --add-repo http://mirrors.aliyun.c
sudo yum makecache fastom/docker-ce/linux/centos/docker-ce.repo
</code></pre></td></tr></table>
</div>
</div></li>
<li>
<p>修改sshd配置</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback">vim /etc/ssh/sshd_config
[修改内容]
UseDNS=no
</code></pre></td></tr></table>
</div>
</div></li>
</ul>
<h3 id="5安装git">5.安装git</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash">yum install -y git

git config --global credential.helper store
git config --global user.name <span class="s2">&#34;zkq&#34;</span>
git config --global user.email wdyxzkq@163.com
</code></pre></td></tr></table>
</div>
</div><h3 id="6安装基础环境">6.安装基础环境</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span><span class="lnt">8
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell">yum install -y wget vim lrzsz unzip git dos2unix

vim /etc/profile
<span class="o">[</span>新增内容<span class="o">]</span>
<span class="nv">PS1</span><span class="o">=</span><span class="s2">&#34;\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h \[\e[36;40m\]\w\[\e[0m\]]\\</span>$<span class="s2"> &#34;</span>
<span class="nb">export</span> <span class="nv">EDITOR</span><span class="o">=</span><span class="s2">&#34;/usr/bin/vim&#34;</span>

<span class="nb">source</span> /etc/profile
</code></pre></td></tr></table>
</div>
</div><p>一个简单的脚本</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">  1
</span><span class="lnt">  2
</span><span class="lnt">  3
</span><span class="lnt">  4
</span><span class="lnt">  5
</span><span class="lnt">  6
</span><span class="lnt">  7
</span><span class="lnt">  8
</span><span class="lnt">  9
</span><span class="lnt"> 10
</span><span class="lnt"> 11
</span><span class="lnt"> 12
</span><span class="lnt"> 13
</span><span class="lnt"> 14
</span><span class="lnt"> 15
</span><span class="lnt"> 16
</span><span class="lnt"> 17
</span><span class="lnt"> 18
</span><span class="lnt"> 19
</span><span class="lnt"> 20
</span><span class="lnt"> 21
</span><span class="lnt"> 22
</span><span class="lnt"> 23
</span><span class="lnt"> 24
</span><span class="lnt"> 25
</span><span class="lnt"> 26
</span><span class="lnt"> 27
</span><span class="lnt"> 28
</span><span class="lnt"> 29
</span><span class="lnt"> 30
</span><span class="lnt"> 31
</span><span class="lnt"> 32
</span><span class="lnt"> 33
</span><span class="lnt"> 34
</span><span class="lnt"> 35
</span><span class="lnt"> 36
</span><span class="lnt"> 37
</span><span class="lnt"> 38
</span><span class="lnt"> 39
</span><span class="lnt"> 40
</span><span class="lnt"> 41
</span><span class="lnt"> 42
</span><span class="lnt"> 43
</span><span class="lnt"> 44
</span><span class="lnt"> 45
</span><span class="lnt"> 46
</span><span class="lnt"> 47
</span><span class="lnt"> 48
</span><span class="lnt"> 49
</span><span class="lnt"> 50
</span><span class="lnt"> 51
</span><span class="lnt"> 52
</span><span class="lnt"> 53
</span><span class="lnt"> 54
</span><span class="lnt"> 55
</span><span class="lnt"> 56
</span><span class="lnt"> 57
</span><span class="lnt"> 58
</span><span class="lnt"> 59
</span><span class="lnt"> 60
</span><span class="lnt"> 61
</span><span class="lnt"> 62
</span><span class="lnt"> 63
</span><span class="lnt"> 64
</span><span class="lnt"> 65
</span><span class="lnt"> 66
</span><span class="lnt"> 67
</span><span class="lnt"> 68
</span><span class="lnt"> 69
</span><span class="lnt"> 70
</span><span class="lnt"> 71
</span><span class="lnt"> 72
</span><span class="lnt"> 73
</span><span class="lnt"> 74
</span><span class="lnt"> 75
</span><span class="lnt"> 76
</span><span class="lnt"> 77
</span><span class="lnt"> 78
</span><span class="lnt"> 79
</span><span class="lnt"> 80
</span><span class="lnt"> 81
</span><span class="lnt"> 82
</span><span class="lnt"> 83
</span><span class="lnt"> 84
</span><span class="lnt"> 85
</span><span class="lnt"> 86
</span><span class="lnt"> 87
</span><span class="lnt"> 88
</span><span class="lnt"> 89
</span><span class="lnt"> 90
</span><span class="lnt"> 91
</span><span class="lnt"> 92
</span><span class="lnt"> 93
</span><span class="lnt"> 94
</span><span class="lnt"> 95
</span><span class="lnt"> 96
</span><span class="lnt"> 97
</span><span class="lnt"> 98
</span><span class="lnt"> 99
</span><span class="lnt">100
</span><span class="lnt">101
</span><span class="lnt">102
</span><span class="lnt">103
</span><span class="lnt">104
</span><span class="lnt">105
</span><span class="lnt">106
</span><span class="lnt">107
</span><span class="lnt">108
</span><span class="lnt">109
</span><span class="lnt">110
</span><span class="lnt">111
</span><span class="lnt">112
</span><span class="lnt">113
</span><span class="lnt">114
</span><span class="lnt">115
</span><span class="lnt">116
</span><span class="lnt">117
</span><span class="lnt">118
</span><span class="lnt">119
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="nb">cd</span> /root
vi linux_init.sh
<span class="o">[</span>内容 start<span class="o">]</span>
<span class="c1">#!/bin/bash</span>
<span class="c1">#update: 2022.04.23</span>
<span class="c1">#version: 1.0.24</span>

<span class="c1">#Global var</span>
<span class="nv">WEBDIR</span><span class="o">=</span>/data/webserver
<span class="nv">WEBSITEDIR</span><span class="o">=</span>/data/website
<span class="nv">WWWDIR</span><span class="o">=</span>/data/www
<span class="nv">TOOLSDIR</span><span class="o">=</span>/data/tools
<span class="nv">EXTDIR</span><span class="o">=</span>/data/tools/php-ext
<span class="nv">CONFDIR</span><span class="o">=</span>/data/conf
<span class="nv">LOGDIR</span><span class="o">=</span>/data/log
<span class="nv">BACKUPDIR</span><span class="o">=</span>/data/backup
<span class="nv">DBDIR</span><span class="o">=</span>/data/database
<span class="nv">APPDIR</span><span class="o">=</span>/data/application
<span class="nv">SCPDIR</span><span class="o">=</span>/data/scp
<span class="nv">LOGFILE</span><span class="o">=</span>/data/log/appinstall.log
<span class="nv">LOCALDIR</span><span class="o">=</span>/data/website/linux_init

<span class="c1">#check net_type</span>
<span class="nv">default_route</span><span class="o">=</span><span class="k">$(</span>ip route show<span class="k">)</span>
<span class="nv">default_interface</span><span class="o">=</span><span class="k">$(</span><span class="nb">echo</span> <span class="nv">$default_route</span> <span class="p">|</span> sed -e <span class="s1">&#39;s/^.*dev \([^ ]*\).*$/\1/&#39;</span> <span class="p">|</span> head -n 1<span class="k">)</span>
<span class="nv">address</span><span class="o">=</span><span class="k">$(</span>ip addr show label <span class="nv">$default_interface</span> scope global <span class="p">|</span> awk <span class="s1">&#39;$1 == &#34;inet&#34; { print $2,$4}&#39;</span><span class="k">)</span>

<span class="c1">#ip addressw</span>
<span class="nv">ip</span><span class="o">=</span><span class="k">$(</span><span class="nb">echo</span> <span class="nv">$address</span> <span class="p">|</span> awk <span class="s1">&#39;{print $1 }&#39;</span><span class="k">)</span>

<span class="nv">LOCALIP</span><span class="o">=</span><span class="si">${</span><span class="nv">ip</span><span class="p">%%/*</span><span class="si">}</span>
<span class="nv">LOCALDIR</span><span class="o">=</span><span class="k">$(</span><span class="nb">cd</span> <span class="s2">&#34;</span><span class="k">$(</span>dirname <span class="s2">&#34;</span><span class="nv">$0</span><span class="s2">&#34;</span><span class="k">)</span><span class="s2">&#34;</span><span class="o">&amp;&amp;</span> <span class="nb">pwd</span><span class="k">)</span>

<span class="k">function</span> base_env <span class="o">()</span>
<span class="o">{</span>
rpm -qa<span class="p">|</span>grep wget <span class="o">&amp;&amp;</span> rpm -qa<span class="p">|</span>grep make <span class="o">&amp;&amp;</span> rpm -qa<span class="p">|</span>grep gcc <span class="o">&amp;&amp;</span> rpm -qa<span class="p">|</span>grep lftp <span class="o">&amp;&amp;</span> rpm -qa<span class="p">|</span>grep gcc-c++ <span class="o">&amp;&amp;</span> rpm -qa<span class="p">|</span>grep ntpdate <span class="o">&amp;&amp;</span> rpm -qa<span class="p">|</span>grep unzip <span class="o">&amp;&amp;</span> rpm -qa<span class="p">|</span>grep git- <span class="o">&amp;&amp;</span> rpm -qa<span class="p">|</span>grep vim&gt; /dev/null
<span class="k">if</span> <span class="o">[</span> <span class="nv">$?</span> -eq <span class="m">1</span> <span class="o">]</span>
<span class="k">then</span>
yum install -y zlib-devel openssl-devel perl net-snmp lsof wget ntpdate make gcc gcc-c++ ncurses* telnet lftp openssh-clients vim lrzsz htop iftop net-tools unzip git vim dos2unix
git config –global core.editor vim
git config --global credential.helper store
<span class="nb">echo</span> -e <span class="s2">&#34;\e[1;32m基础环境已更新\e[0m&#34;</span>
<span class="k">fi</span>

cat /etc/profile <span class="p">|</span>grep PS1 &gt;&gt; /dev/null
<span class="k">if</span> <span class="o">[</span> <span class="nv">$?</span> -eq <span class="m">1</span> <span class="o">]</span>
<span class="k">then</span>
  <span class="nb">echo</span> <span class="s1">&#39;PS1=&#34;\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h \[\e[36;40m\]\w\[\e[0m\]]\\$ &#34;&#39;</span> &gt;&gt; /etc/profile
  <span class="nb">echo</span> <span class="s1">&#39;HISTTIMEFORMAT=&#34;%F %T `whoami` &#34;&#39;</span> &gt;&gt; /etc/profile
  <span class="nb">echo</span> <span class="s1">&#39;export EDITOR=&#34;/usr/bin/vim&#34;&#39;</span> &gt;&gt; /etc/profile
<span class="k">fi</span>

mkdir -p <span class="nv">$WEBDIR</span>
mkdir -p <span class="nv">$WEBSITEDIR</span>
mkdir -p <span class="nv">$TOOLSDIR</span>
mkdir -p <span class="nv">$DBDIR</span>
mkdir -p <span class="nv">$APPDIR</span>
mkdir -p <span class="nv">$SCPDIR</span>
mkdir -p <span class="nv">$LOGDIR</span>
mkdir -p <span class="nv">$BACKUPDIR</span>
mkdir -p <span class="nv">$CONFDIR</span>
mkdir -p <span class="nv">$EXTDIR</span>

<span class="k">if</span> <span class="o">[</span> <span class="sb">`</span>getenforce<span class="sb">`</span> <span class="o">==</span> <span class="s1">&#39;Enforcing&#39;</span> <span class="o">]</span>
<span class="k">then</span>
  setenforce <span class="m">0</span>
  sed -i <span class="s1">&#39;s/SELINUX=enforcing/SELINUX=disabled/&#39;</span> /etc/selinux/config
  sed -i <span class="s1">&#39;s/SELINUX=enforcing/SELINUX=disabled/&#39;</span> /etc/sysconfig/selinux
  <span class="nb">echo</span> -e <span class="s2">&#34;\e[1;32m已关闭selinux\e[0m&#34;</span>
<span class="k">fi</span>
systemctl stop firewalld
<span class="nb">echo</span> -e <span class="s2">&#34;\e[1;32m已关闭系统防火墙\e[0m&#34;</span>

cp -pr ./tools/* <span class="nv">$TOOLSDIR</span>/
cp -pr ./conf/* <span class="nv">$CONFDIR</span>/
cp -pr ./code/* <span class="nv">$WEBSITEDIR</span>/
cp -pr ./scp/* <span class="nv">$SCPDIR</span>/
<span class="nb">echo</span> -e <span class="s2">&#34;\e[1;32m已安装工具包\e[0m&#34;</span>
<span class="o">}</span>

<span class="c1">#function end</span>

<span class="nb">echo</span> -e <span class="s2">&#34;\e[1;32m======================================================\e[0m&#34;</span>
<span class="nb">echo</span> -e <span class="s2">&#34;\e[1;32m选择要安装的服务类型,目前支持以下项目:\e[0m&#34;</span>
<span class="nb">echo</span> -e <span class="s2">&#34;\e[1;36m(1): 创建规范目录,安装基础库环境,关闭selinux,配置时间同步
</span><span class="s2">(q): 退出\e[0m&#34;</span>

<span class="nb">echo</span> -e <span class="s2">&#34;\e[1;32m请输入序号:\e[0m&#34;</span>
<span class="nb">read</span> options

<span class="k">function</span> main <span class="o">()</span>
<span class="o">{</span>
  <span class="k">case</span> <span class="s2">&#34;</span><span class="nv">$options</span><span class="s2">&#34;</span> in

  1<span class="o">)</span>
	  clear
	  base_env
          <span class="nb">echo</span> -e <span class="s2">&#34;\e[1;32m基础环境配置完毕\e[0m&#34;</span>
	  <span class="nb">cd</span> <span class="nv">$LOCALDIR</span>
	  sh ./init.sh
	  <span class="p">;;</span>
  q<span class="o">)</span>
	  <span class="nb">echo</span> <span class="s2">&#34;退出脚本&#34;</span>
	  <span class="nb">exit</span>
	  <span class="p">;;</span>
  *<span class="o">)</span>
	  clear
    <span class="nb">echo</span> -e <span class="s2">&#34;\e[1;31m请输入正确的选项\e[0m&#34;</span>
    <span class="nb">cd</span> <span class="nv">$LOCALDIR</span>
	  sh ./init.sh
<span class="k">esac</span>
<span class="o">}</span>

main <span class="nv">$@</span>
<span class="nb">exit</span> <span class="nv">$?</span>
<span class="o">[</span>内容 end<span class="o">]</span>
chmod +x linux_init.sh
./init.sh
选0 回车
</code></pre></td></tr></table>
</div>
</div><h3 id="7安装linux_init项目">7.安装linux_init项目</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash">mkdir -p /data/website
<span class="nb">cd</span> /data/website
git clone https://gitee.com/dysoso/linux_init.git
<span class="nb">cd</span> linux_init
./init.sh

选1回车,安装基础环境
</code></pre></td></tr></table>
</div>
</div><h3 id="8lnmp环境配置">8.lnmp环境配置</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash">使用linux_init项目<span class="o">(</span>https://gitee.com/dysoso/linux_init.git<span class="o">)</span>配置
</code></pre></td></tr></table>
</div>
</div><h3 id="9docker和docker-compose环境">9.docker和docker-compose环境</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash">使用dnmp项目<span class="o">(</span>https://gitee.com/dysoso/dnmp.git<span class="o">)</span>配置
</code></pre></td></tr></table>
</div>
</div><h3 id="10golang环境配置">10.golang环境配置</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span><span class="lnt">14
</span><span class="lnt">15
</span><span class="lnt">16
</span><span class="lnt">17
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="c1">#安装Go</span>
curl -R -O https://dl.google.com/go/go1.17.6.linux-amd64.tar.gz
rm -rf /usr/local/go <span class="o">&amp;&amp;</span> tar -C /usr/local -xzf /data/tools/go1.17.6.linux-amd64.tar.gz
mkdir -p /root/go

<span class="c1">#添加执行命令至环境变量</span>
vim /etc/profile
【内容】
<span class="nb">export</span> <span class="nv">GOROOT</span><span class="o">=</span>/usr/local/go
<span class="nb">export</span> <span class="nv">GOPATH</span><span class="o">=</span>/root/go
<span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span><span class="nv">$PATH</span>:<span class="nv">$GOPATH</span>/bin:<span class="nv">$GOROOT</span>/bin

<span class="nb">source</span> /etc/profile

<span class="c1">#GOMOD和GOPROXY配置</span>
go env -w <span class="nv">GO111MODULE</span><span class="o">=</span>on
go env -w <span class="nv">GOPROXY</span><span class="o">=</span>https://goproxy.cn,direct
</code></pre></td></tr></table>
</div>
</div>
    </div>

    <div class="post-copyright">
  <p class="copyright-item">
    <span class="item-title">文章作者</span>
    <span class="item-content">ZhangKQ</span>
  </p>
  <p class="copyright-item">
    <span class="item-title">上次更新</span>
    <span class="item-content">
        2022-02-10
        
    </span>
  </p>
  
  
</div>
<div class="post-reward">
  <input type="checkbox" name="reward" id="reward" hidden />
  <label class="reward-button" for="reward">赞赏支持</label>
  <div class="qr-code">
    
    <label class="qr-code-image" for="reward">
        <img class="image" src="/qrcode/wechat-qr-code.jpg">
        <span>微信打赏</span>
      </label>
    <label class="qr-code-image" for="reward">
        <img class="image" src="/qrcode/alipay-qr-code.jpg">
        <span>支付宝打赏</span>
      </label>
  </div>
</div><footer class="post-footer">
      <div class="post-tags">
          <a href="/tags/linux/">linux</a>
          <a href="/tags/%E8%99%9A%E6%8B%9F%E6%9C%BA/">虚拟机</a>
          <a href="/tags/%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83/">开发环境</a>
          <a href="/tags/%E9%85%8D%E7%BD%AE/">配置</a>
          </div>
      <nav class="post-nav">
        <a class="prev" href="/post/version_controller/git/git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/">
            <i class="iconfont icon-left"></i>
            <span class="prev-text nav-default">[git]Git常用命令</span>
            <span class="prev-text nav-mobile">上一篇</span>
          </a>
        <a class="next" href="/post/dev_language/php/swoole/hyperf%E5%AE%89%E8%A3%85%E4%B8%8E%E5%85%A5%E9%97%A8/">
            <span class="next-text nav-default">[hyperf]hyperf安装及入门</span>
            <span class="next-text nav-mobile">下一篇</span>
            <i class="iconfont icon-right"></i>
          </a>
      </nav>
    </footer>
  </article>
        </div>
        

  

  

      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="social-links">
      <a href="mailto:wdyxzkq@163.com" class="iconfont icon-email" title="email"></a>
      <a href="https://github.com/dysoso" class="iconfont icon-github" title="github"></a>
      <a href="https://gitee.com/dysoso" class="iconfont icon-gitlab" title="gitlab"></a>
  <a href="https://blog.nevergiveup.tech/index.xml" type="application/rss+xml" class="iconfont icon-rss" title="rss"></a>
</div>

<div class="copyright">
  <span class="power-by">
    由 <a class="hexo-link" href="https://blog.nevergiveup.tech/">blog.nevergiveup.tech</a> 强力驱动
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    主题 - 
    <a class="theme-link" href="https://github.com/olOwOlo/hugo-theme-even">Even</a>
  </span>

  

  <span class="copyright-year">
    &copy; 
    2021 - 
    2022<span class="heart"><i class="iconfont icon-heart"></i></span><span><a href="https://beian.miit.gov.cn/">蜀ICP备2021005948号-1</a></span>
  </span>
</div>

    </footer>

    <div class="back-to-top" id="back-to-top">
      <i class="iconfont icon-up"></i>
    </div>
  </div>
  
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/slideout@1.0.1/dist/slideout.min.js" integrity="sha256-t+zJ/g8/KXIJMjSVQdnibt4dlaDxc9zXr/9oNPeWqdg=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.js" integrity="sha256-XVLffZaxoWfGUEbdzuLi7pwaUJv1cecsQJQqGLe7axY=" crossorigin="anonymous"></script>



<script type="text/javascript" src="/js/main.min.c99b103c33d1539acf3025e1913697534542c4a5aa5af0ccc20475ed2863603b.js"></script>


<script type="application/javascript">
var doNotTrack = false;
if (!doNotTrack) {
	window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
	ga('create', 'never-give-up', 'auto');
	ga('set', 'anonymizeIp', true);
	ga('send', 'pageview');
}
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>







</body>
</html>
